<%@page import="com.alibaba.fastjson.JSONObject"%>
<%@page import="com.meila.cms.util.config.Property"%>
<%@page import="com.meila.cms.entity.User"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="el"  uri="toJson.com/el-common" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"  %>
<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

	User user=((User) session.getAttribute("loginUser"));

%>
<!DOCTYPE HTML>
<html lang="zh-CN">
  <head>
    <base href="<%=basePath%>">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <title>我的零部件库</title>
    

	<link href="resources/css/system/carDesign/design.css" rel="stylesheet"></link>
	
	<!-- <script src="lib/jquery/1.11.3/jquery.min.js"></script>
	<script src="lib/bootstrap-3.3.5/js/bootstrap.min.js"></script> -->
    
  </head>
  
  <body class="client-body">
  		<jsp:include page="../common/design-head3.jsp"></jsp:include>
  		
  		<script src="resources/js/system/partsDesign/myPartsCommon.js"></script>
	  	<script src="resources/js/system/partsDesign/designMyParts.js"></script>
	  	<script src="resources/js/system/partsDesign/uploadFile.js"></script>
	  	<script src="resources/js/ajaxfileupload.js"></script>
  		<!-- 左 -->
  		<div class="design-body design-bodyLeft">
			<div class="design-leftTag">零部件选择</div>
			   
			<div class="design-leftmenu fontBox clearfix">
				<c:forEach var="dict" items="${partTypeList}">
					<a class="a-black ${myPartsModel.partsType==dict.value? 'activeFont':''}" href="javascript:getMyPartList(${dict.value})">${dict.name}</a>
				</c:forEach>
			</div>
			
			<div class="left-twoImgList listImgBox clearfix">
				<c:forEach var="myparts" items="${myPartList}">
					<div class="left-twoImgBlock leftImgBlock ${myparts.id==myPartsModel.id? 'activeImg':''}">
						<div class="left-twoImgBox"><img src="<%=Property.getProperty("FILESERVER_PATH") %>?id=${myparts.physicalmap}"/></div>
						<div class="left-oneImgName">${myparts.designame}</div>
						<input type="hidden" value="${el:toJsonString(myparts)}">
					</div>
				</c:forEach>
			</div>

		</div>
  		
  		<!-- 中 -->
  		<div class="design-body design-bodyMiddle">
  			<div class="design-btnBox btnBox clearfix">
				<!-- <a class="a-black activeBtn" href="javascript:;">平面</a> -->
				<!-- <a class="a-black" href="javascript:;">3D</a> -->
			</div>
			
			<div class="design-middleActions">
				<a class="a-white activeBtn" href="javascript:;"><i class="fa fa-arrow-right"></i></a>
				<a class="a-white" href="javascript:download(${param.id});"><i class="fa fa-download"></i></a>
				<a class="a-white" href="javascript:location.reload();"><i class="fa fa-refresh"></i></a>
			</div>
			
			<div class="middle-towImgList clearfix">
				<a class="middle-oneImgBox" href="javascript:;"><img id="twoDid_img"/></a>
			</div>
  		</div>
  		
  		<!-- 右 -->
  		<div class="design-body design-bodyRight">
			<div class="design-leftTag">细节设置</div>
			
			<div class="design-rightForm pdm-rightForm">
				<form class="form-horizontal" id="myPartDesignform">
				   <div class="rightFormUp">
				   		<div class="form-group">
				   			<label class="col-sm-4 control-label">文件名</label>
						    <div class="col-sm-8">
						      <input id="designame" name="designame" type="text" class="form-control" value="${param.designame}" onblur="designameVerify('${param.designame}',<%=user==null? null:user.getId()%>)"/>
						    </div>
						</div>
				   		<div class="form-group">
						    <label class="col-sm-4 control-label">零件号</label>
						    <div class="col-sm-8">
						      <input id="partsNo" name="partsNo" type="text" class="form-control" value="${myPartsModel.partsNo}"/>
						      <input id="id" name="id" type="hidden" class="form-control" value="${myPartsModel.id}"/>
						      <input id="twoDid" name="twoDid" type="hidden" class="form-control" value="${myPartsModel.twoDid}"/>
						      <input id="threeDid" name="threeDid" type="hidden" class="form-control" value="${myPartsModel.threeDid}"/>
						      <input id="userid" name="userid" type="hidden" class="form-control" value="${myPartsModel.userid}"/>
						      <input id="carid" name="carid" type="hidden" class="form-control" value="${myPartsModel.carid}"/>
						      <input id="partsType" name="partsType" type="hidden" class="form-control" value="${myPartsModel.partsType}"/>
						      <input id="designid" name="designid" type="hidden" class="form-control" value="${myPartsModel.designid}"/>
						      <input id="physicalmap" name="physicalmap" type="hidden" class="form-control" value="${myPartsModel.physicalmap}">
						    </div>
						  </div>
						  
						  <div class="form-group">
						    <label class="col-sm-4 control-label">零件名</label>
						    <div class="col-sm-8">
						      <input id="partsName" name="partsName" type="text" class="form-control" value="${myPartsModel.partsName}"/>
						    </div>
						  </div>
						  
						  <div class="form-group">
						    <label class="col-sm-4 control-label">材料</label>
						    <div class="col-sm-8">
						      <input id="material" name="material" type="text" class="form-control" value="${myPartsModel.material}"/>
						    </div>
						  </div>
						  
						  <div class="form-group">
						    <label class="col-sm-4 control-label">备注</label>
						    <div class="col-sm-8">
						      <textarea id="comment" name="comment">${myPartsModel.comment}</textarea>
						    </div>
						  </div>
				   </div><!-- rightFormUp -->
				 	
				 	<div id="myproperty" class="rightFormUp">
				 		<c:forEach varStatus="status" var="myproperty" items="${myPartsPropertyList}">
				 			<div class="form-group">
				 				<label class="col-sm-4 control-label">${myproperty.propertyName}</label>
				 				<div class="col-sm-8">
				 					<input type="hidden" name="partsid" class="form-control" value="${myproperty.partsid}"/>
				 					<input type="text" class="form-control" name="propertyValue_deci" id="value${status.index}" value="${myproperty.propertyValue/100}" onchange="$('#${status.index}').val(this.value*100)" onkeyup="amount(this)"/>
						      		<input type="hidden" id="${status.index}" name="propertyValue" class="form-control" value="${myproperty.propertyValue}"/>
						    	</div>
				 			</div>
				 		</c:forEach>										  
						  
				 	</div><!-- rightFormUp -->
				 	
				 	<div class="rightFormDown">
				 		<div class="form-group">
						    <label class="col-sm-4 control-label">编程图</label>
						    <div class="col-sm-8">
						        <div id="Programdiv" class="file-box">
									<input type="button" value="选择文件" class="file-input" onclick="flagFile.click()">
							        <input id="programFile" type="file" name="flagFile" style="display: none;" onchange="flagContent.value=value" >
									<input type="text" name="flagContent" style="display: none;" >
									<input type="hidden" id="programmeid" name="programmeid" value="${myPartsModel.programmeid}" />
									<c:if test="${empty myPartsModel.programmeid}">
										<span id="programSpan" class="file-name file-name2">未上传文件</span>
									</c:if>
									<c:if test="${not empty myPartsModel.programmeid}">
										<span id="programSpan" class="file-name file-name2">${myPartsModel.programmeName}</span>
									</c:if>
								</div>
								<input id="programBtn" class="file-submit2" type="button" value="上传" onclick="uploadFile('programSpan','programFile','programBtn','Programdiv','upload_error',<%=user==null? null:user.getPhone()%>)">
						    </div>
						 </div>
						 
						 <div class="form-group">
						    <label class="col-sm-4 control-label">产品制作图</label>
						    <div class="col-sm-8">
						        <div id="Productdiv" class="file-box">
									<input type="button" value="选择文件" class="file-input" onclick="flagFile2.click()">
							        <input id="productFile" type="file" name="flagFile2" style="display: none;" onchange="flagContent2.value=value" >
									<input type="text" name="flagContent2" style="display: none;" >
									<input type="hidden" id="productid" name="productid" value="${myPartsModel.productid}" />
									<c:if test="${empty myPartsModel.productid}">
										<span id="productSpan" class="file-name file-name2">未上传文件</span>
									</c:if>
									<c:if test="${not empty myPartsModel.productid}">
										<span id="productSpan" class="file-name file-name2">${myPartsModel.productName}</span>
									</c:if>
								</div>
								<input id="productBtn" class="file-submit2" type="button" value="上传" onclick="uploadFile('productSpan','productFile','productBtn','Productdiv','upload_error',<%=user==null? null:user.getPhone()%>)">
						    </div>
						 </div>
						 
						 <div class="form-group">
						    <label class="col-sm-4 control-label">模具图</label>
						    <div class="col-sm-8">
						       <div id="Modlediv" class="file-box">
									<input type="button" value="选择文件" class="file-input" onclick="flagFile3.click()">
							        <input id="modleFile" type="file" name="flagFile3" style="display: none;" onchange="flagContent3.value=value" >
									<input type="text" name="flagContent3" style="display: none;" >
									<input type="hidden" id="modleid" name="modleid" value="${myPartsModleid}" />
									<c:if test="${empty myPartsModel.modleid}">
										<span id="modleSpan" class="file-name file-name2">未上传文件</span>
									</c:if>
									<c:if test="${not empty myPartsModel.modleid}">
										<span id="modleSpan" class="file-name file-name2">${myPartsModel.modleName}</span>
									</c:if>
								</div>
								<input id="modleBtn" class="file-submit2" type="button" value="上传" onclick="uploadFile('modleSpan','modleFile','modleBtn','Modlediv','upload_error',<%=user==null? null:user.getPhone()%>)">
						    </div>
						 </div>
						 
						 <div class="form-group">
						    <div id="upload_error" style="display: none" class="col-sm-offset-4 col-sm-8 mpdm-fileHint">
						      	目前仅支持.stp格式文件上传
						    </div>
						 </div>
					 </div>
					 	
			        <div class="form-group">
					    <div class="col-sm-12 rightForm-footBtn">
				            <a class="btn btn2 a-white" href="javascript:this.location.reload()">重置</a>
				            <a class="btn btn2 right a-white" href="javascript:submitForm('${myPartsModel.id}');">保存修改</a>
					    </div>
				    </div>
				</form>
			</div>
		</div>
  	
  	<!-- 下载modal -->
	<div class="modal fade bs-example-modal-sm" id="loadModal" tabindex="-1" role="dialog" aria-labelledby="loadModalLabel" data-backdrop="static">
	  <div class="modal-dialog modal-sm" role="document">
	    <form action="front/partDesign/downloadFileBychose" method="post" id="downloadForm">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		        <h4 class="modal-title">请选择所需文档</h4>
		      </div>
		      
		      <div class="modal-body load-modalBody clearfix">
		        <input name="designid"  id="designid" type="hidden" value="${param.id}"/> 
		        <label><input name="chose" type="checkbox" value="1" /> 2D文档 </label>
		        <label><input name="chose" type="checkbox" value="2" /> 3D文档 </label>
				<label><input name="chose" type="checkbox" value="3" /> 编程图 </label>
				<label><input name="chose" type="checkbox" value="4" /> 产品制作图 </label>
				<label><input name="chose" type="checkbox" value="5" /> 模具图 </label>
		      </div>
		      
		      <div class="modal-footer">
		      	<button type="button" class="btn btn1" onclick="submitDownload()">确定下载</button>
		        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
		      </div>
		    </div>
	     </form>
	  </div>
	</div>
		
  	<!-- Modal -->
	<div class="modal fade" id="myPartsModifyModal" tabindex="-1" role="dialog" aria-labelledby="carModifyModalLabel" data-backdrop="static">
	  <div class="modal-dialog modal-sm">
	    <form action="">
		    <div class="modal-content">
		      
		      <div class="modal-body">
				  <div class="carModal-body">
				    <i class="fa fa-check-circle"></i>
				    <span>您已保存成功！</span>
				  </div>
		      </div>
		      
		      <div class="modal-footer carModal-footer">
		        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
		        <%-- <button type="button" class="btn btn2 a-white" onclick="submitForm('${myPartsModel.id}')">保存并退出</button> --%>
		      </div>
		      
		    </div>
	     </form>
	  </div>
	</div>
    
  </body>
<script type="text/javascript">
$(document).ready(function(){
	var twoDid=$("#twoDid").val();
	if(twoDid==''){
	}else{
		$("#twoDid_img").attr('src',FILESERVER_PATH+"?id="+twoDid);
	};
	if($('#myproperty .form-group').length){
		$("#myproperty").append("<div class='form-group'>"+
        			    "<div class='pdm-rightForm-unit'>单位：毫米(mm) </div>"+
        			  "</div>");
	}else{
		
	};
});
</script>
</html>
